﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using MovieRental_Presentation.Helpers;
using System.Windows;

namespace MovieRental_Presentation.Validation
{
    public class QuantityValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value == DependencyProperty.UnsetValue)
                return new ValidationResult(false, "Invalid quantity");
            bool isValid = ComponentManager.Instance.EditionComponent.VerifyQuantity((int)value, EditionId);
            return (isValid) ? new ValidationResult(true, null) : new ValidationResult(false, "Invalid quantity. Check the number of editions in stock.");
        }

        public Guid EditionId { set; get; }
    }
}
